package com.ellricky.baselib.util;

import android.app.Activity;
import android.text.TextUtils;
import android.widget.ImageView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.bumptech.glide.request.RequestOptions;

public class GlideUtil {

    public static void into(Activity activity, String url, ImageView iv) {
        into(activity, url, iv, 0);

    }

    public static void into(Activity activity, String url, ImageView iv, int defaultIcon) {
        if (TextUtils.isEmpty(url)) {
            if (defaultIcon > 0) iv.setImageResource(defaultIcon);
            else
                iv.setImageDrawable(null);
        } else {
            Glide.with(activity)
                    .load(url)
                    .apply(new RequestOptions().skipMemoryCache(true)
                            .diskCacheStrategy(DiskCacheStrategy.NONE))
                    .into(iv);
        }

    }
}
